package com.example.foobar.entity;

import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.IdType;

import java.text.ParseException;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.Version;
import com.baomidou.mybatisplus.annotation.TableId;
import io.geekidea.springbootplus.framework.util.DateUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;

/**
 * 滴滴订单
 *
 * @author 郑英奔
 * @since 2021-10-26
 */
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "DidiOrders对象")
public class DidiOrders extends BaseEntity {
    private static final long serialVersionUID = 1L;

    @NotNull(message = "id不能为空", groups = {Update.class})
    @ApiModelProperty("ID")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty("CPA返佣金额，单位：分")
    private Integer cpaProfit;

    @ApiModelProperty("CPA类型, 当前暂未开放")
    private String cpaType;

    @ApiModelProperty("CPS返佣金额，单位：分")
    private Integer cpsProfit;

    @ApiModelProperty("是否被风控 0-否 1-是")
    private Integer isRisk;

    @ApiModelProperty("下单用户openUID")
    private String openUid;

    @ApiModelProperty("订单id")
    private String orderId;

    @ApiModelProperty("订单状态 2:已付款 8:已退款")
    private String orderStatus;

    @ApiModelProperty("下单用户openUID")
    private Integer payPrice;

    @ApiModelProperty("支付时间")
    private Date payTime;

    @ApiModelProperty("159: 滴滴加油， 210: 滴滴网约车， 393: 滴滴货运")
    private String productId;

    @ApiModelProperty("推广位ID")
    private String promotionId;

    @ApiModelProperty("退款金额，单位：分")
    private Integer refundPrice;

    @ApiModelProperty("退款时间，秒级时间戳")
    private Date refundTime;

    @ApiModelProperty("推送次数")
    private Integer retryTimes;

    @ApiModelProperty("来源ID")
    private String sourceId;

    @ApiModelProperty("推送状态: 1.已预估归因 2.预估订单已推送 3.预估订单推送失败 4.结算提交 5.结算提交失败 6.结算取消 7.结算成功 8.结算失败")
    private Integer status;

    @ApiModelProperty("Create Time")
    private Date createTime;

    @ApiModelProperty("Update Time")
    private Date updateTime;

    @NotNull(message = "日期不能为空")
    @ApiModelProperty("日期")
    private Date date;

    public void setPayTime(String payTime) {
        try {
            Date date = DateUtil.LongToDare(Long.valueOf(payTime));
            this.payTime = date;
        } catch (ParseException e) {
            e.printStackTrace();
        }

    }

    public void setRefundTime(String refundTime) {
        try {
            Date date = DateUtil.LongToDare(Long.valueOf(refundTime));
            this.refundTime = date;
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }

    public Date getDate(){
        return this.payTime;
    }

}
